//
//  VEAssociationDetailViewController.m
//  VEMoneyPorject
//
//  Created by BlueWind on 2018/9/13.
//  Copyright © 2018年 陈建. All rights reserved.
//

#import "VEAssociationDetailViewController.h"
#import "VEAssiciationDongtaiViewController.h"
#import "VEAssociationIntrodViewController.h"

@interface VEAssociationDetailViewController ()

@property (nonatomic, strong) NSArray *musicCategories;

@property (nonatomic, strong) UIView *redView;


@end

@implementation VEAssociationDetailViewController

- (UIView *)redView {
    if (!_redView) {
        _redView = [[UIView alloc] initWithFrame:CGRectZero];
        _redView.backgroundColor = [UIColor colorWithRed:168.0/255.0 green:20.0/255.0 blue:4/255.0 alpha:1];
    }
    return _redView;
}

- (NSArray *)musicCategories {
    if (!_musicCategories) {
        _musicCategories = @[@"动态",@"介绍"];
    }
    return _musicCategories;
    
}

- (instancetype)init {
    if (self = [super init]) {
        self.titleSizeNormal = 14;
        self.titleSizeSelected = 14;
        self.menuViewStyle = WMMenuViewStyleLine;
        self.progressColor = kCommonRedColor;
        self.automaticallyCalculatesItemWidths = YES;
        self.titleColorSelected = kCommonRedColor;
        self.titleColorNormal = [UIColor blackColor];
        self.showOnNavigationBar = YES;


    }
    return self;
}

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    self.navigationController.navigationBar.barStyle = UIBarStyleDefault;
    
    [self.navigationController.navigationBar setBarTintColor:[UIColor whiteColor]];
    self.navigationController.navigationBar.translucent = NO;
    
}

- (UIStatusBarStyle)preferredStatusBarStyle
{
    return UIStatusBarStyleDefault;
}

- (void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    //    self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
}


- (void)viewDidLoad {
    [super viewDidLoad];
    
}

- (void)viewDidLayoutSubviews {
    [super viewDidLayoutSubviews];
    self.redView.frame = CGRectMake(0, CGRectGetMaxY(self.menuView.frame), self.view.frame.size.width, 2.0);
}


-(void)gobackToVC{
    
    [self.navigationController popToViewController:self.navigationController.viewControllers[0] animated:YES];
    
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


#pragma mark - Datasource & Delegate
- (NSInteger)numbersOfChildControllersInPageController:(WMPageController *)pageController {
    return self.musicCategories.count;
}

- (UIViewController *)pageController:(WMPageController *)pageController viewControllerAtIndex:(NSInteger)index {
    
    if (index == 0) {
        VEAssiciationDongtaiViewController *vc = [VEAssiciationDongtaiViewController new];
        vc.assionId = self.assionId;
        return vc;
    } else {
        VEAssociationIntrodViewController *vc = [VEAssociationIntrodViewController new];
        vc.assionId = self.assionId;
        vc.isJoin = self.isJoin;
        return vc;
    }

    

}

- (NSString *)pageController:(WMPageController *)pageController titleAtIndex:(NSInteger)index {
    return self.musicCategories[index];
}

- (CGRect)pageController:(WMPageController *)pageController preferredFrameForMenuView:(WMMenuView *)menuView {
    
    CGFloat leftMargin = self.showOnNavigationBar ? 50 : 0;
    //    CGFloat originY = self.showOnNavigationBar ? 0 : CGRectGetMaxY(self.navigationController.navigationBar.frame);
    return CGRectMake(leftMargin, 0, self.view.frame.size.width - 2*leftMargin, 44);
}

- (CGRect)pageController:(WMPageController *)pageController preferredFrameForContentView:(WMScrollView *)contentView {
    
    CGFloat originY = CGRectGetMaxY([self pageController:pageController preferredFrameForMenuView:self.menuView]);
    //    if (self.menuViewStyle == WMMenuViewStyleTriangle) {
    //        originY += self.redView.frame.size.height;
    //    }
    return CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
}

@end
